//
//  ButtonCell.m
//  Guazi
//
//  Created by koolearn on 11-6-21.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#import "ButtonCell.h"


@implementation ButtonCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 44)] autorelease];
        label.backgroundColor = [UIColor clearColor];
        label.textAlignment = UITextAlignmentCenter;
        label.font = [UIFont boldSystemFontOfSize:18];
        label.textColor = [UIColor whiteColor];
        [self.contentView addSubview:label];
    }
    return self;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}


- (void)setTitle:(NSString*)title
{
    label.text = title;
}


- (void)setImage:(UIImage*)image imagePressed:(UIImage*)imagePressed
{
    UIImageView* background = [[[UIImageView alloc] initWithImage:image] autorelease];
    self.backgroundView = background;
    
    if ( imagePressed ) {
        UIImageView* backgroundPressed = [[[UIImageView alloc] initWithImage:imagePressed] autorelease];
        self.selectedBackgroundView = backgroundPressed;
    }
    [self setNeedsDisplay];
}


- (void)layoutSubviews
{
    [super layoutSubviews];
}


- (void)dealloc
{
    [super dealloc];
}

@end
